package org.shoukaiseki.springtest.oracledemo.common.utils.random;

import org.apache.commons.lang3.RandomUtils;

import java.util.Random;

/**
 * com.hkedou.common.random.RandomChar <br>
 *
 * @author 蒋カイセキ    Japan-Tokyo  2018-10-15 19:44:09<br>
 * ブログ http://shoukaiseki.blog.163.com/<br>
 * E-メール jiang28555@Gmail.com<br>
 **/

public class RandomChar {

    /**
     * 随机英文大写字母
     * @return
     */
    public static char randomUpperCaseEnglish() {
        return (char)RandomUtils.nextInt(65,91);
    }

    /**
     * 随机英文小写字母
     * @return
     */
    public static char randomLowerCaseEnglish(){
        return (char)RandomUtils.nextInt(97,123);
    }


    /**
     * 随机数字0-9
     * @return
     */
    public static char randomInteger(){
        return (char)RandomUtils.nextInt(48,58);
    }

    /**
     * 随机符号<br>
     * 33-47:符号 48-57:数字(10) 58-64:符号(7) 65-90:大写字母(26) 91-96:符号(6) 97-122:小写字母(26) 123-126:符号(4)
     * <br>
     * >47 +10
     * <br>
     * >54 +36
     * <br>
     * @return
     */
    public static char randomSymbol(){
        int i = RandomUtils.nextInt(33, 65);
        if(i>60){
            return (char)(i+62);
        }
        if(i>54){
            return (char)(i+36);
        }
        if(i>47){
            return (char)(i+10);
        }
        return (char)i;
    }

}

